package com.example.rmqdemo.config;


import org.springframework.amqp.core.*;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author:徐莹
 * @Date:2025/02/28 16:56:42
 */


@Configuration
public class RabbitMQConfig {
//    @Bean
//    public Queue queue() {
//        return QueueBuilder.durable("queue").build();
//    }
//
//    @Bean
//    public DirectExchange directExchange() {
//        return ExchangeBuilder.directExchange("exchange").build();
//    }
//    @Bean
//    public MessageConverter messageConverter(){
//        return new Jackson2JsonMessageConverter();
//    }
    @Bean
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }
    @Bean
    public Exchange fanout_exchange(){
        return ExchangeBuilder.fanoutExchange("fanout_exchange").build();
    }

    @Bean
    public Queue fanout_queue_email(){
        return new Queue("fanout_queue_email2");
    }

    @Bean
    public Queue fanout_queue_sms(){
        return new Queue("fanout_queue_sms2");
    }
    @Bean
    public Binding bindingEmail(){
        return
                BindingBuilder.bind(fanout_queue_email()).to(fanout_exchange()).with("").noargs();
    }
    @Bean
    public Binding bindingSms(){
        return
                BindingBuilder.bind(fanout_queue_sms()).to(fanout_exchange()).with("").noargs();
    }

}
